package com.zilue.security.algorithm.digest;

import com.zilue.security.algorithm.DigestAlgorithm;

import java.util.*;

/**
 * Created by zilue on 2017/1/17.
 */
public class SimpleDigest implements DigestAlgorithm {
    public String getMapDigest(Map<String, String> map) {
        String orgnial = "";
        if (map != null) {
            Set<String> keySet = map.keySet();
            List<String> keyList = new ArrayList<String>(keySet.size());
            keyList.addAll(keySet);
            Collections.sort(keyList);
            for (String paramName : keyList) {
                String value=map.get(paramName);
                if (value==null||value.trim().equals(""))
                    continue;
                orgnial += "&" + paramName + "=" + value;
            }
            orgnial = orgnial.replaceFirst("&", "");
        }
        return orgnial;
    }
}
